package com.ruoyi.information.testTask;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.information.domain.back.UserStatisticsBack;
import com.ruoyi.information.mapper.back.SysUserBackMapper;
import com.ruoyi.information.mapper.back.SysUserNeedBackMapper;
import com.ruoyi.information.mapper.back.UserStatisticsBackMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("testTask")
public class testTask {

    @Autowired
    private SysUserBackMapper sysUserMapper;

    @Autowired
    private SysUserNeedBackMapper sysUserNeedMapper;

    @Autowired
    private UserStatisticsBackMapper userStatisticsMapper;

    public void userStatistics(){
        UserStatisticsBack statistics = new UserStatisticsBack();
        /*总注册数*/
        long totalCount = sysUserMapper.selectSysUserListAll(null).size();

        statistics.setTotalCount(totalCount);

        /*已注册数*/
        long registerCount = totalCount -sysUserNeedMapper.selectSysUserNeedNotList();
        statistics.setRegisterCount(registerCount);

        /*未通过用户*/
        long failCount = sysUserNeedMapper.selectSysUserNeedNotCarryList();
        statistics.setFailCount(failCount);

        /*待审核用户*/
        long reviewCount = sysUserNeedMapper.selectSysUserNeedAuditList();
        statistics.setReviewCount(reviewCount);

        /*创建时间*/
        statistics.setCreateTime(DateUtils.getNowDate());


        userStatisticsMapper.insertUserStatistics(statistics);
    }

}
